package com.example.prom.dangwen.y2023.thread;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // 输入学生人数、姓名和身高
//        System.out.print("请输入学生人数：");
        int n = scanner.nextInt();
        String[] names = new String[n];
        int[] heights = new int[n];
//        System.out.print("请输入学生姓名（用空格分隔）：");
        for (int i = 0; i < n; i++) {
            names[i] = scanner.next();
        }
//        System.out.print("请输入学生身高（用空格分隔）：");
        for (int i = 0; i < n; i++) {
            heights[i] = scanner.nextInt();
        }

        // 构造学生对象数组
        Student[] students = new Student[n];
        for (int i = 0; i < n; i++) {
            students[i] = new Student(names[i], heights[i]);
        }

        // 按身高降序排序并输出名单
        Arrays.sort(students, Comparator.comparingInt(Student::getHeight).reversed());
        System.out.println(Arrays.toString(students));

        scanner.close();
    }
}

class Student {
    private String name;
    private int height;

    public Student(String name, int height) {
        this.name = name;
        this.height = height;
    }

    public String getName() {
        return name;
    }

    public int getHeight() {
        return height;
    }

    @Override
    public String toString() {
        return name;
    }
}

